#include <stdio.h>
#define LENGTH 5

// 函数参数是指针类型，则调用时需要传递地址或指针变量或者数组名
double get_avg(int *, int);
void func(int *); 
int main(){

    int num = 100;
    int *ptr = &num;
    int arr[LENGTH] = {13, 23, 43, 75, 97};

    printf("%d\n", num);
    func(&num); // 传入变量时要取地址
    printf("%d\n", num);
    func(ptr); // 直接传入指针
    printf("%d\n", num);

    printf("主函数中arr地址%p\n", arr);
    double avg = get_avg(arr, LENGTH);
    printf("%.2lf\n", avg);

    return 0;
}

void func(int *p){

    (*p)++;


    return;
}

double get_avg(int *arr, int length){

    double sum = 0;
    double avg;
    printf("形参arr的地址%p\n", arr);
    for(int i = 0; i < length; i++){
    sum += arr[i];

    }
    avg = sum / length;
    return avg;
}